import 'package:flutter/material.dart';
import 'package:kiosk_model/kiosk_model.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _kioskModel = KioskModel();

  bool _isKiosk = false;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () => _kioskModel.owner().then((value) => print(value)),
          child: const Icon(Icons.add),
        ),
        body: Center(
          child: Column(
            children: [
              const SizedBox(height: 50),
              FutureBuilder(
                future: _kioskModel.owner(),
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    return Text('Owner: $_isKiosk');
                  }
                  return const CircularProgressIndicator();
                },
              ),
              const SizedBox(height: 50),
              ElevatedButton(
                onPressed: () async {
                  await _kioskModel.startKioskMode();
                },
                child: const Text('Start Kiosk'),
              ),
              const SizedBox(height: 50),
              ElevatedButton(
                onPressed: () async {
                  await _kioskModel.stopKioskMode();
                },
                child: const Text('Stop Kiosk'),
              ),

              ElevatedButton(
                onPressed: () async {
                  await _kioskModel.hideNavigationBar(false);
                },
                child: const Text('Hide NavigationBar'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
